{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">补单管理</div>
    <div class="layui-card-header">实际支出总额：<span style="color: red;font-size: 18px" id="payMoneyContainer"></span>
    </div>
    <div class="layui-card-header">刷单数：<span style="color: red;font-size: 18px" id="tabBaoNums"></span></div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('tao_bao/add')}"
                   data-auth-edit="{:$auth->check('tao_bao/edit')}"
                   data-auth-delete="{:$auth->check('tao_bao/del')}"
                   data-auth-recyclebin="{:$auth->check('tao_bao/recyclebin')}"
            ></table>
        </div>
    </div>
</div>
<script type="text/html" id="barTool">
    <a data-open='{:url("edit")}?id={{ d.id }}'
       class="layui-btn layui-btn-warm layui-btn-xs {:$auth->check('member/edit')?'':'layui-hide'}"
       title="查看详情">编辑</i></a>

    <a data-open='{:url("admin/log/index")}?id={{ d.id }}'
       class="layui-btn layui-btn layui-btn-xs {:$auth->check('member/edit')?'':'layui-hide'}"
       title="查看详情">查看明细</i></a>

    <a href='{:url("del")}?id={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('staff.index/del')?'':'layui-hide'}">删除</i></a>

</script>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            modify_url: "{:url('multi')}",
            recyclebin_url: "{:url('recyclebin')}",
        };

        table.render({
            init: init,
            toolbar: ['refresh', 'add', 'delete'],
            url: '{:url("index")}',
            cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'date', align: 'center', title: '日期', minWidth: 120},
                    // {field: 'id', align: 'center', title: 'ID', minWidth: 80},
                    {field: 'cate.name', align: 'center', title: '店铺名称', minWidth: 120},
                    {field: 'zhuchi', align: 'center', title: '主持', minWidth: 120},
                    {field: 'nums', align: 'center', title: '刷单数', minWidth: 80},
                    {
                        field: 'price',
                        align: 'center',
                        title: '刷单单价',
                        minWidth: 100,
                        search: 'between',
                        searchTip: '单价'
                    },
                    {
                        field: 'money',
                        align: 'center',
                        title: '实际支出',
                        minWidth: 100,
                        search: 'between',
                        searchTip: '付款金额'
                    },
                    {
                        field: 'goods_price',
                        align: 'center',
                        title: '商品单价',
                        minWidth: 100,
                        search: 'between',
                        searchTip: '单价'
                    },


                    {
                        field: 'total_money',
                        align: 'center',
                        title: '总支出',
                        minWidth: 100,
                        search: 'between',
                        searchTip: '付款金额'
                    },
                    {
                        field: 'status',
                        align: 'center',
                        width: 120,
                        title: '状态',
                        unresize: true,
                        templet: yznTable.formatter.switch,
                        tips: "已结清|进行中"
                    },
                    {
                        field: 'create_time',
                        title: '创建日期',
                        minWidth: 80,
                        width: 180,
                        search: 'range',
                        templet: yznTable.formatter.datetime
                    },
                    {
                        fixed: 'right',
                        width: 90,
                        field: 'operate',
                        search: false,
                        title: '操作',
                        templet: yznTable.formatter.tool,
                        operat: ['edit', 'delete']
                    }

                ]
            ],
            done: function (res, curr, count) {
                var payMoney = res.payMoney;
                var tabBaoNums = res.tabBaoNums;

                // 将 payMoney 渲染到页面的某个元素中
                $('#payMoneyContainer').text(payMoney + "元");
                $('#tabBaoNums').text(tabBaoNums + "单");
            },
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}